package com.mycompany.webapp.action;

import java.util.List;

import com.mycompany.dto.EventBookingStatusDto;
import com.mycompany.service.BookingManager;
import com.mycompany.service.EventManager;

/**
 * Action for Bookings page.
 */
public class BookingAction extends BaseAction{
	private static final long 			serialVersionUID = -8022294166982509118L;
	private EventManager				eventManager;
	private BookingManager				bookingManager;
	private List<EventBookingStatusDto>	eventBookingStatusList;
	

	public void setEventManager(EventManager eventManager) {
		this.eventManager = eventManager;
	}

	public BookingManager getBookingManager() {
		return bookingManager;
	}

	public void setBookingManager(BookingManager bookingManager) {
		this.bookingManager = bookingManager;
	}

	public List<EventBookingStatusDto> getEventBookingStatusList() {
		return eventBookingStatusList;
	}

	public void setEventBookingStatusList(
			List<EventBookingStatusDto> eventBookingStatusList) {
		this.eventBookingStatusList = eventBookingStatusList;
	}

	public EventManager getEventManager() {
		return eventManager;
	}



    @Override
	public String execute() {
        return SUCCESS;
    }
    
	public String editBookingsForUser() {
		String username = getRequest().getRemoteUser();
		eventBookingStatusList = bookingManager.getBookingsForUser(username);
						
		return SUCCESS;	
	}
	
	public String updateBookingsForUser() {	
		String userName = getRequest().getRemoteUser();
		bookingManager.updateBookings(userName, eventBookingStatusList);
		
		return SUCCESS;
	}
	
	@Override
	public String cancel() {
		return CANCEL;
	}

}
